<template>
	<view>
		<ikz-loading :css-data="loading_css"></ikz-loading>
		<form @submit="formSubmit" class="main">
			<view class="ikz-add">
				<view class="addRec-menu-o">
					<view class="addRec-menu-o-left">姓名</view>
					<view class="addRec-menu-o-right">
						<input name="name" placeholder="请输入姓名" style="height:60rpx;" :value="name"
							cursor-spacing="5" value="" />
					</view>
				</view>
				<view class="addRec-menu-o">
					<view class="addRec-menu-o-left">开户行名称</view>
					<view class="addRec-menu-o-right">
						<input name="openBankNm" placeholder="请输入开户行名称" style="height:60rpx;" cursor-spacing="5" :value="openBankNm" />
					</view>
				</view>
				<view class="addRec-menu-o">
					<view class="addRec-menu-o-left">银行卡号</view>
					<view class="addRec-menu-o-right">
						<input name="cardNo" type="number"  placeholder="请输入银行卡号" style="height:60rpx;" :value="cardNo" />
					</view>
				</view>
			</view>
			<button class="ikz-add-address-btn" form-type="submit">修改</button>
		</form>
	</view>
</template>

<script>
	import ikz from '@/pages/Common/tools';
	import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
	var app = getApp();
	export default {
		components: {
			ikzLoading
		},
		data() {
			return {
				local: '', //具体地址 值
				name:'',
				id:'',
				openBankNm:'',
				cardNo:'',
				current_addr: {}, //点击获取的用户信息
				color: '',
				loading_css: {
					display: 'flex'
				},
				group_name: '请选择收货地址'
			};
		},
		onLoad: function(options) {
			this.name=options.name,
			this.openBankNm=options.openBankNm,
			this.cardNo=options.cardNo
		},
		onShow: function() {
			this.loading_css.display = 'none';
		},
		methods: {
			//编辑银行卡提交
			formSubmit: function(e) {
				if (e.detail.value.name == '') {
					wx.showToast({
						title: '姓名不能为空',
						icon: 'error',
						duration: 2000
					})
					return
				}
				if (e.detail.value.openBankNm == '') {
					wx.showToast({
						title: '开户行不能为空',
						icon: 'error',
						duration: 2000
					})
					return
				}
				if (e.detail.value.cardNo == '') {
					wx.showToast({
						title: '卡号不能为空',
						icon: 'error',
						duration: 2000
					})
					return
				}
				uni.showModal({
					title: '提示',
						content: '请确认银行卡信息无误后，点击确认按钮进行修改',
						showCancel: true,
						success: function(res) {
							if (res.confirm) {
								uni.showLoading({
									title: '加载中'
								});
								var path = '/xyb/bank/edit';
								var data = {
									name: e.detail.value.name,
									openBankNm: e.detail.value.openBankNm,
									cardNo: e.detail.value.cardNo,
								}
								ikz.post(path, data, (res) => {
									console.log("编辑成功",res)
									if (res.data.code) {
										// 获取id
										// app.globalData.bankcardid = res.data.data.id;
										// uni.setStorageSync("bankcardid", res.data.data.id);
										wx.showToast({
											title: '银行卡编辑成功',
											icon: 'success',
											duration: 1000
										});
										setTimeout(function() {
											uni.navigateBack({
												delta: 1 // 回退前 delta(默认为1) 页面
											});
											uni.hideLoading()
										}, 1000)
									} else {
										uni.showModal({
											title: '提示',
											content: res.data.msg,
											showCancel: false,
											success: function(res) {}
										});
										uni.hideLoading()
									}
								});
							} else if (res.cancel) {
								
							}
							
						}
				});	
			},
			
		},
	};
</script>

<style>
	page {
		background: #f2f2f2;
	}

	.main {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		/* width:100%; */
	}

	.ikz-add {
		width: 90%;
		margin: 10px auto;
		border-radius: 10rpx;
		background: #fff;
	}

	.addRec-menu-o {
		font-family: Arial, Helvetica, sans-serif;
		font-size: 36rpx;
		border-bottom: 1px solid #eee;
	}

	.reciver-top {
		height: 70rpx;
		background-color: #2d90e5;
		text-align: center;
		color: white;
		line-height: 70rpx;
	}

	.addRec-menu-o-left {
		line-height: 60rpx;
		width: 25%;
	}

	.addRec-menu-o {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding: 20rpx;
		font-size: 30rpx;
	}

	.addRec-menu-o-right {
		width: 70%;
		color: gainsboro;
		font-size: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.addRec-menu-o-right input {
		height: 70rpx;
		color: black;
	}

	.addRec-menu-o-right button {
		margin-left: 120rpx;
	}

	.ikz-add-address-btn {
		position: relative;
		width: 90%;
		margin-top: 60rpx;
		background: linear-gradient(to right, #FBAB7E, #F8C66D);
		border: none;
		border-radius: 50px;
		color: #fff;
	}

	.ikz-cell-ft-in-access {
		width: 7px;
		height: 7px;
		border-top: 1px solid #828282;
		border-right: 1px solid #828282;
		transform: rotate(45deg);
	}
</style>
